package com.pomr.util.common;

import java.util.HashMap;
import java.util.Map;
/**
 * 返回给客户端的结果
 * @author Administrator
 *
 */
public class ResponseData {
	private final String message;
    private final int code;// 成功代码
    private final Map<String, Object> data = new HashMap<String, Object>();
    
    

    public String getMessage() {
        return message;
    }

    public int getCode() {
        return code;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public ResponseData putDataValue(String key, Object value) {
        data.put(key, value);
        return this;
    }

    private ResponseData(int code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public static ResponseData custom(String message){
    	return new ResponseData(10086, message);//自定义错误
    }

	public static ResponseData ok() {
        return new ResponseData(200, "成功");
    }
	
	public static ResponseData fail() {
        return new ResponseData(205, "失败");
    }

    public static ResponseData notFound() {
        return new ResponseData(404, "数据未找到");
    }

    public static ResponseData badRequest() {
        return new ResponseData(400, "错误的请求");
    }

    public static ResponseData forbidden() {
        return new ResponseData(403, "禁用错误");
    }

    public static ResponseData unauthorized() {
        return new ResponseData(401, "请求头部信息缺失");
    }

    public static ResponseData serverInternalError() {
        return new ResponseData(500, "服务器数据错误");
    }

    public static ResponseData customerError() {
        return new ResponseData(1001, "客户端错误");
    }
    
    public static ResponseData exceptionError() {
        return new ResponseData(1002, "异常错误");
    }
    
    public static ResponseData userError() {
        return new ResponseData(1003, "用户错误");
    }
    
    public static ResponseData tokenError() {
        return new ResponseData(1004, "Token超时");
    }
    
    public static void main(String[] args) {
		String str = "100";
		System.out.println(Long.valueOf(str));
	}
}
